fix(schema): preserve schema registry transaction invariants - #804
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef6202128d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| registrations = self._registrations | ||
| else: | ||
| pending = self._pending.get(transaction_identity) | ||
| registrations = pending.registrations if pending is not None else {} |
There was a problem hiding this comment.
Avoid using committed schemas as transaction witnesses
When a transaction re-registers a schema already present in _registrations, this branch ignores the committed cache and adds that existing URI to the pending set. If the same transaction then registers a new schema and rolls back, _reconcile_pending() sees the pre-existing URI as its witness and incorrectly promotes the entire pending set, including the rolled-back schema; subsequent registration returns the cached URI without recreating its missing descriptor. Preserve committed cache hits inside transactions, or track whether each witness was created by the transaction.
Useful? React with 👍 / 👎.
Fixes #757 and #758.
Problem
A failed schema registration could leave an empty transaction-pending entry. Once that transaction ended, reconciliation called
next()on the empty schema map and bricked the registry. Separately, a transaction could bind a second Pydantic model to an already committed schema URI because the conflict check ignored committed bindings.Change
Create pending state only after descriptor registration succeeds, and keep committed registrations out of the transaction cache until reconciliation confirms commit. Reconciliation defensively discards an empty pending entry.
For model-backed schemas, calculate the deterministic descriptor URI and check both committed and transaction-pending bindings before descriptor registration. A conflicting model therefore cannot leave partial pending state.
Regression coverage
The schema-registry component suite now covers failed transactional descriptor registration, cross-transaction and intra-transaction model conflicts, same-model reattachment, and rollback followed by re-registration.
Validation
make test-component TESTS=tests/component/schemas/test_schema_registry.py— 19 passedmake check-static— passed